 <meta charset="utf-8">
 <div class="row" >
 <div  class="col-md-6">
  <div class="box">
            <div class="box-header with-border">
               <form id="positionSearchFromA" role="form" class="form-inline">
              	<h4>属于该岗位人员</h4> 
                    <div class="form-group">
                    <label>姓名</label>
                         <input name="name" id="name" type="text" placeholder="" class="form-control">
                    </div>
                  <button type="button"  class="btn btn-info pull-right m-t-n-xs" onclick="searchA();"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	<div class="row">
 	  <div class="col-md-12">
 	                           <div class="btn-group " id="tableToolbarA" role="group">
                                    <button type="button" class="btn btn-default" onclick="removeFromPosition();">
                                        <i class="glyphicon glyphicon-minus" aria-hidden="true"></i> 移除
                                    </button>
                           </div> 
                                
           <table id="positionTableA" data-mobile-responsive="true" ></table>
 	  </div>
 	</div>
 </div>
</div>
 </div>
 <div  class="col-md-6">
   <div class="box">
            <div class="box-header with-border">
            <h4>不属于该岗位的用户</h4>
               <form id="positionSearchFormB" role="form" class="form-inline">
                    <div class="form-group">
                    <label>姓名</label>
                         <input name="name" id="name" type="text" placeholder="" class="form-control">
                    </div>
                     <button type="button"  class="btn btn-info pull-right m-t-n-xs" onclick="searchB();"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	<div class="row">
 	  <div class="col-md-12">
 	                       <div class="btn-group " id="tableToolbarB" role="group">
                                    <button type="button" class="btn btn-default" onclick="addToPosition();">
                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                                    </button>
                           </div> 
                                
           <table id="positionTableB" data-mobile-responsive="true" ></table>
 	  </div>
 	</div>
 </div>
</div>
</div>

<script>
var param=zfesLayerEditDg.getLayerParam();
var jqTableDomA=$("#positionTableA");
var jqFormDomA=$("#positionSearchFromA");
var jqToolbarDomA=$("#tableToolbarA");
var isInPosition="inPosition";
var positionId=param.id;
var initUrlA=host_auth+"/sys/sysPosition/loadUserForPosition?positionId="+positionId+"&isInPosition="+isInPosition;

var jqTableDomB=$("#positionTableB");
var jqFormDomB=$("#positionSearchFormB");
var jqToolbarDomB=$("#tableToolbarB");
var isInPosition="notInPosition";
var initUrlB=host_auth+"/sys/sysPosition/loadUserForPosition?positionId="+positionId+"&isInPosition="+isInPosition;

$(function(){
	initData();
});
function initData(){
	var columns=[
					{checkbox:true},
					{field:'perName',title:'名称',width:60,sortable:true},
				    {field:'perNum',title:'编号',width:60}, 
				];
	zfesBstable.laodTable(jqTableDomA,jqFormDomA,jqToolbarDomA,initUrlA,columns,{height:500});
	zfesBstable.laodTable(jqTableDomB,jqFormDomB,jqToolbarDomB,initUrlB,columns,{height:500});
}
function removeFromPosition(){
	 var ids=zfesBstable.getRowIds(jqTableDomA);
	 alertSwal.confirm("移除人员","是否从本岗位中移除",function(){
			 	var ajaxUrl = host_auth+"/sys/sysPosition/removeUserFromPosition";
				var param = { "userIds":ids,"positionId":positionId};
				zfesAjax.ajaxTodo(ajaxUrl, param, function(data) {
					alertSwal.successText(data.message);
	    			zfesBstable.refresh(jqTableDomA);
					zfesBstable.refresh(jqTableDomB);
				}); 
	 });
}
function addToPosition(){
	var ids=zfesBstable.getRowIds(jqTableDomB);
	 alertSwal.confirm("增加人员","是否为本岗位增加人员",function(){
			 	var ajaxUrl = host_auth+"/sys/sysPosition/addUserToPosition";
			 	var param = { "userIds":ids,"positionId":positionId};
				zfesAjax.ajaxTodo(ajaxUrl, param, function(data) {
					alertSwal.successText(data.message);
	    			zfesBstable.refresh(jqTableDomA);
					zfesBstable.refresh(jqTableDomB);
				}); 
	 });
}
function searchA(){
	zfesBstable.reload(jqTableDomA);
}

function searchB(){
	zfesBstable.reload(jqTableDomB);
}
</script>

 </div>
 


